﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DreamBox.Admin.Posts
{
    public partial class ClassUpdate : BLL.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int CID = Htss.Platform.Core.Transform.GetInt(Request.QueryString["CID"], 0);
                if (CID > 0)
                {
                    DAL.PSelect ps = new DAL.PSelect();
                    DataTable dt = ps.Select("dbox_PostsClass", "*", "CID=" + CID);
                    if (dt.Rows.Count > 0)
                    {
                        tbox_ClassName.Text = dt.Rows[0]["ClassName"].ToString();
                        tbox_Description.Text = dt.Rows[0]["Description"].ToString();
                        tbox_Sort.Text = dt.Rows[0]["Sort"].ToString();
                        cbox_IsStatus.Checked = bool.Parse(dt.Rows[0]["IsStatus"].ToString());
                    }
                }
            }
        }

        protected void btn_Post_Click(object sender, EventArgs e)
        {
            Model.PostsClass m = new Model.PostsClass();
            m.CID = Htss.Platform.Core.Transform.GetInt(Request.QueryString["CID"], 0);
            m.ClassName = tbox_ClassName.Text;
            m.Description = tbox_Description.Text;

            m.IsStatus = cbox_IsStatus.Checked;

            m.Sort = Htss.Platform.Core.Transform.GetInt(tbox_Sort.Text, 99);

            DAL.MAction action = new DAL.MAction();
            if (action.Update(m))
            {
                BLL.Admin.Tips.DetailedTips(this, "操作", "/Posts/ClassList.aspx", "1");
            }
        }
    }
}